<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Object.defineProperty方法的使用</h1>
</body>
<script>
    const user={

    }
    Object.defineProperty(user,'name',{
        get(){
            console.log('name属性被访问了');
            return 'jack';
        },
        set(value){
            console.log('name属性被修改了:',value);
        }
    });
    console.log(user.name);
    user.name='rose'
</script>
</html>